package com.wpp.controller;

import com.wpp.dao.ResumeDao;
import com.wpp.pojo.ResumePO;
import com.wpp.service.IResumeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author by wpp25
 * @Classname DemoController
 * @Description
 * @Date 2020/10/23 22:15
 */
@Controller
@RequestMapping("/resume/api")
public class ResumeController {

    @Autowired
    private IResumeService resumeService;


    @RequestMapping("/list")
    public String queryList(ModelMap map) {
        map.addAttribute("list",resumeService.findAll());
        return "resume-list";
    }

    @RequestMapping(value = "/edit",method = RequestMethod.POST)
    @ResponseBody
    public Map<String,List<ResumePO>> edit(@RequestBody ResumePO resumePO) {
        resumeService.editOne(resumePO);

        return new HashMap<>();
    }

    @RequestMapping(value = "/save",method = RequestMethod.POST)
    @ResponseBody
    public Map<String,List<ResumePO>> save(@RequestBody ResumePO resumePO) {
        resumeService.editOne(resumePO);

        return new HashMap<>();
    }

    @RequestMapping(value = "/delete",method = RequestMethod.POST)
    @ResponseBody
    public Map<String,List<ResumePO>> delete(@RequestBody ResumePO resumePO) {
        resumeService.deleteById(resumePO.getId());
        return new HashMap<>();
    }
}
